package com.ojl.xmlparser;

import org.w3c.dom.Element;

import com.ojl.devs.Utilities;
import java.util.ArrayList;

public class ReadXMLTest1 {

	public static void main(String argv[]) {
			  
		XmlParse xp = new XmlParse("raw\\file.xml");
		Utilities utils = new Utilities();
		
		System.out.println("Root element : " + xp.getRoot(true));
				
		ArrayList<?> elements = xp.getElements((Element) xp.getRoot());
		for (Object element: elements)
		{
			ArrayList<?> lst = xp.getElements((Element) element);
			
			for (Object ele: lst)
			{
				Element elem = (Element) ele;
				String name = xp.getElementName(elem);
				String type = xp.getElementType(elem);
				System.out.println("NAME: " + name + " Type " + type);
				if (name=="nickname")
				{
					ArrayList<?> spl = xp.getElements(elem, true);
					utils.arrayPrint(spl);
					
					ArrayList<String> attrs = xp.getAttributes(elem);
					utils.arrayPrint("Attr: ", attrs);
					for (String attr : attrs)
						System.out.println("Attribute '" + attr  + "' Value: " + xp.getAttribute(elem, attr));
				}
						
			}
		}

	}
	
}
